//
//  SurePayVC.m
//  LoveTrail
//
//  Created by giantumbrella on 15/6/30.
//  Copyright (c) 2015年 赵娟. All rights reserved.
//

#import "SurePayVC.h"
#import "CommonMacro.h"
@interface SurePayVC ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong) UIView *lineView;
@property (nonatomic,strong) UILabel *titleLabel;
@property (nonatomic,strong) UILabel *numLabel;
@property (nonatomic,strong) UIButton *jifenButton;
@property (nonatomic,strong) UIImageView *iconImageView;
@property (nonatomic,strong) UIImageView *checkImageView;
@end

@implementation SurePayVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = self.pathTitle;
    self.navigationItem.rightBarButtonItem = nil;
    
    //创建子控件
    [self createSubviews];
}

#pragma mark 创建tableView 子视图
- (void)createSubviews
{
    //1.创建tableView
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0,SCREEN_WIDTH , SCREEN_HEIGHT*0.74)];
//    self.tableView.backgroundColor = [UIColor redColor];
    [self.view addSubview:self.tableView];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    //2.
    
    //3.
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *ID = @"surePayCell";
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }

    if (indexPath.section==0) {
        if (indexPath.row==0) {
            cell.textLabel.text = [NSString stringWithFormat:@"实付款：358元"];
            cell.textLabel.textColor = UIColorWithRGBA(247, 99, 63, 1);
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
      
        }
       else
        {
            for (int i=0; i<2; i++) {
                self.lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0+cell.frame.size.height*i, SCREEN_WIDTH, 1)];
                [cell addSubview:self.lineView];
                self.lineView.backgroundColor = UIColorWithRGBA(209, 209, 209, 1);
            }
            cell.textLabel.text = @"可用50积分抵";
            //￥5
            self.numLabel = [[UILabel alloc] initWithFrame:CGRectMake(cell.bounds.size.width*0.37, 17, cell.bounds.size.width*0.2, cell.bounds.size.height*0.4)];
            [cell addSubview:self.numLabel];
//            self.numLabel.backgroundColor = [UIColor redColor];
            self.numLabel.text = @"￥5";
            self.numLabel.textColor = UIColorWithRGBA(248, 111, 149, 1);
            //积分点击按钮
            self.jifenButton = [[UIButton alloc] initWithFrame:CGRectMake(cell.bounds.size.width*0.8, cell.bounds.size.height*0.15, cell.bounds.size.width*0.1, cell.bounds.size.width*0.1)];
            [cell addSubview:self.jifenButton];
            self.jifenButton.backgroundColor = [UIColor grayColor];
        }
    }
    else
    {
        //微信图标
        self.iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(30, 10, cell.bounds.size.width*0.18, cell.bounds.size.width*0.18)];
        [cell addSubview:self.iconImageView];
//        self.iconImageView.image = [UIImage imageNamed:@""];
        self.iconImageView.backgroundColor = [UIColor greenColor];
        self.iconImageView.layer.cornerRadius = 5;
        self.iconImageView.clipsToBounds = YES;
        //选中打钩
        self.checkImageView = [[UIImageView alloc] initWithFrame:CGRectMake(cell.bounds.size.width*0.8, cell.bounds.size.height*0.5, cell.bounds.size.width*0.1, cell.bounds.size.width*0.1)];
        [cell addSubview:self.checkImageView];
        self.checkImageView.backgroundColor = [UIColor blueColor];
//        cell.selectionStyle = UITableViewCellSelectionStyleDefault;
    }
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section==0) {
        if (indexPath.row==0) {
            return 100;
        }
        else
        {
            return 50;
        }
    }
    else
    {
        return 80;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section==0) {
        return 0;
    }
    else
    {
        return 50;
    }
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    UILabel *label = [[UILabel alloc] init];
    label.text = @"请选择支付方式：";
    label.textColor = UIColorWithRGBA(148, 148, 148, 1);
    label.font = [UIFont systemFontOfSize:20];
    return label.text;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
